package com.flying.client.utils;

import java.io.UnsupportedEncodingException;

public class StringHelper {
	/**
	 * empty string
	 */
	public static final String empty = "";
	
	/**
	 * check the str whether it equal null or is a empty string
	 * @param str
	 * @return
	 */
	public static boolean isEmptyOrNull(String str)
	{
		return str == null || str.length() <= 0;
	}
	
	public static byte[] getByte(String str,String charset)
	{
		if (isEmptyOrNull(str))
			return null;
		
		try {
			return str.getBytes(charset);
		} catch (UnsupportedEncodingException e) {
			return null;
		}
	}
	
	public static byte[] getByte(String str)
	{
		return getByte(str,"UTF-8");
	}
}
